//medicine_menu开头
$(function(){
	$(".right_ul li a").css("float","left");
	$(".right_ul li a").eq(0).css({"border":"none","paddingRight":0,"color":"#e55251"})
	$(".right_ul li:last>a").css("border","none");
	$(".right_ul li:last>span").css({"float":"left","margin":"0 -5px 0 5px","color":"#e54948"});
	$(".right_ul li:eq(4)>a").css({"color":"#cbaf82","font-weight":"800"})
	
})

//1药网搜索框
//http://www.111.com.cn/search/search.action?keyWord=h
//https://dd-search.jd.com/?key=aaa&callback=
$seTxt = $(".medicine_search #txt");
$oUl = $(".medicine_search .ul1");
$seTxt.focus(function(){
	$(this).val("");
});
$seTxt.keyup(function(){
	var $str = $(this).val();
	$oUl.html("");
	$oUl.css("display","block");
//	$("<script src=https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + $str + "&cb=fn").appendTo("head:eq(0)");
	$(("<script>"),{
		src:"https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + $str + "&cb=fn" 
	}).appendTo("head:eq(0)");
});
function fn(data){
	data.s.forEach(function(value,index){
		let oLi = document.createElement("li");
		oLi.innerHTML = value;
		$oUl.append(oLi);
	})
}
//console.log($(".medicine_search .ul1 li"))
$(".medicine_search .ul1 li").each(function(index,value){
	$(this).hover(function(){
		console.log(1)
		$(this).css("background-color","#ccc");
	},function(){
		$(this).css("background-color","#fff");
	})
})
//$(".medicine_search .ul1 li").hover(function(){
//	console.log(213)
//	$(this).css("background-color","#ccc");
//},function(){
//	$(this).css("background-color","#fff")
//});
//$(".medicine_search .ul1 li").click(function(){
//	$("#txt").value = $(this).html();
//})



/*+++++++++++++++++++++侧边栏回到顶部++++++++++++++++++++*/
$(".sidabar .oTop").click(function(){
	$("html,body").animate({"scrollTop":0},1000)
})

/*+++++++++++++++++++++二级菜单++++++++++++++++++++*/
$(".nav_ul1 li:gt(0)").hover(function(){
	$(this).animate({"margin-left":"5px"},300);
	$(this).children("a").css({"color":"#e96875"});
},function(){
	$(this).animate({"margin-left":0},300);
	$(this).children("a").css({"color":"#f1f1f1"});
})
//轮播图
//动态获取的方法，插件一起用有加载先后的问题
//$.getJSON("JSON/banner.json",function(json){
//	var data = json[0].banner;
//	$(data).each(function(index,value){
//		var $str = $('<div class="swiper-slide"><img src=' + value + '></div>');
//		$(".swiper-wrapper").append($str);
////		console.log($str.get(0));
//	})	
//})

//轮播图插件的方法
var mySwiper = new Swiper ('.swiper-container', {
	direction: 'horizontal',
	loop: true,
	autoplayDisableOnInteraction:false,
	pagination: '.swiper-pagination',
    preventClicks : true,
    autoplay: 3000
})   
//个数写死的，插件可用
$.getJSON("JSON/banner.json",function(json){
	var data = json[0].banner;
	$(".swiper-slide:eq(1) img").attr("src",data[0]);
	$(".swiper-slide:eq(2) img").attr("src",data[1]);
	$(".swiper-slide:eq(3) img").attr("src",data[2]);
	$(".swiper-slide:eq(4) img").attr("src",data[3]);
	$(".swiper-slide:eq(5) img").attr("src",data[4]);
	$(".swiper-slide:eq(6) img").attr("src",data[5]);
	$(".swiper-slide:eq(7) img").attr("src",data[6]);
	$(".swiper-slide:eq(8) img").attr("src",data[0]);
	$(".swiper-slide:eq(9) img").attr("src",data[6]);
})
/////////////////////////////中间的广告条
$.getJSON("JSON/banner.json",function(json){
	var data = json[10].advert;
//	console.log(data);
	$(".medicine_advert2").attr("src",data[1]);
})
/////////////////////////////////// 1F家庭常备药
//1F的轮播图
$.getJSON("JSON/banner.json",function(json1){	
	var data_1F = json1[1].banner_1F;
//	console.log(data_1F)
	$("#banner11 img").attr("src",data_1F[0]);
	$("#banner12 img").attr("src",data_1F[1]);
	$("#banner13 img").attr("src",data_1F[2]);
})
//商品的json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_1F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F1_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
//		console.log($F1_commdity)
		$(".F1_banner .commdity_ul2").append($F1_commdity)
	})
})

/////////////////////////////////// 2F专业用药
//2F的轮播图
$.getJSON("JSON/banner.json",function(json2){	
	var data_2F = json2[2].banner_2F;
//	console.log(data_1F)
	$("#banner21 img").attr("src",data_2F[0]);
	$("#banner22 img").attr("src",data_2F[1]);
	$("#banner23 img").attr("src",data_2F[2]);
})
//2F商品json获取
$.getJSON("JSON/commdity.json",function(str2){
	var data = str2.commdity_2F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F2_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F2_banner .commdity_ul2").append($F2_commdity)
	})
})
/////////////////////////////中间的广告条advert3
$.getJSON("JSON/banner.json",function(json10){
	var data = json10[10].advert;
//	console.log(data);
	$(".medicine_advert3").attr("src",data[2]);
})

/////////////////////////////////// 3F医疗器械
//3F的轮播图
$.getJSON("JSON/banner.json",function(json3){	
	var data_3F = json3[3].banner_3F;
//	console.log(data_1F)
	$("#banner31 img").attr("src",data_3F[0]);
	$("#banner32 img").attr("src",data_3F[1]);
	$("#banner33 img").attr("src",data_3F[2]);
})
//3F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_3F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F3_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F3_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F3_banner .commdity_ul2").append($F3_commdity)
	})
})
/////////////////////////////////// 4F隐形眼镜
//4F的轮播图
$.getJSON("JSON/banner.json",function(json4){	
	var data_4F = json4[4].banner_4F;
//	console.log(data_1F)
	$("#banner41 img").attr("src",data_4F[0]);
	$("#banner42 img").attr("src",data_4F[1]);
	$("#banner43 img").attr("src",data_4F[2]);
})
//4F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_4F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F4_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F4_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F4_banner .commdity_ul2").append($F4_commdity)
	})
})
/////////////////////////////////// 5F滋补保健
//5F的轮播图
$.getJSON("JSON/banner.json",function(json5){	
	var data_5F = json5[5].banner_5F;
//	console.log(data_1F)
	$("#banner51 img").attr("src",data_5F[0]);
	$("#banner52 img").attr("src",data_5F[1]);
})
//5F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_5F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F5_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F5_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F5_banner .commdity_ul2").append($F5_commdity)
	})
})
/////////////////////////////////// 6F维生素钙
//6F的轮播图
$.getJSON("JSON/banner.json",function(json6){	
	var data_6F = json6[6].banner_6F;
//	console.log(data_1F)
	$("#banner61 img").attr("src",data_6F[0]);
	$("#banner62 img").attr("src",data_6F[1]);
	$("#banner63 img").attr("src",data_6F[2]);
})
//5F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_6F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F6_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F6_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F6_banner .commdity_ul2").append($F6_commdity)
	})
})
/////////////////////////////////// 7F药妆个护
//7F的轮播图
$.getJSON("JSON/banner.json",function(json7){	
	var data_7F = json7[7].banner_7F;
//	console.log(data_1F)
	$("#banner71 img").attr("src",data_7F[0]);
	$("#banner72 img").attr("src",data_7F[1]);
	$("#banner73 img").attr("src",data_7F[2]);
})
//7F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_7F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F7_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F7_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F7_banner .commdity_ul2").append($F7_commdity)
	})
})
/////////////////////////////////// 8F情趣用品
//8F的轮播图
$.getJSON("JSON/banner.json",function(json8){	
	var data_8F = json8[8].banner_8F;
//	console.log(data_1F)
	$("#banner81 img").attr("src",data_8F[0]);
	$("#banner82 img").attr("src",data_8F[1]);
	$("#banner83 img").attr("src",data_8F[2]);
})
//8F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_8F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F8_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F8_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F8_banner .commdity_ul2").append($F8_commdity)
	})
})
/////////////////////////////////// 9F母婴用品
//9F的轮播图
$.getJSON("JSON/banner.json",function(json9){	
	var data_9F = json9[9].banner_9F;
//	console.log(data_1F)
	$("#banner91 img").attr("src",data_9F[0]);
	$("#banner92 img").attr("src",data_9F[1]);
	$("#banner93 img").attr("src",data_9F[2]);
})
//9F商品json获取
$.getJSON("JSON/commdity.json",function(str){
	var data = str.commdity_9F;
//	console.log(data);
	$(data).each(function(index,value){
		var $F9_commdity = $(`<li>
								<a href="###"><img src="` + value.pic + `"/></a>
								<a href="###">`+ value.text +`</a>
								<p>`+ value.price + `</p>
							</li>`)
		$(".F9_banner .commdity_ul2 li a").attr("title",value.text)
		$(".F9_banner .commdity_ul2").append($F9_commdity)
	})
})
/////////////////////////品牌旗舰店
function connectOA(){
	for(var i = 0; i<20; i++){
		var $oConnectUl1 = $(`<li><a href="###"></a></li>`);
		$(".medicine_Connect .connect_ul1").append($oConnectUl1);
//		var $oConnectUl2 = $(`<li><a href="###"></a></li>`);
//		$(".medicine_Connect .connect_ul2").append($oConnectUl2);
		$(".connect_top span:eq(0)").hover(function(){
			$(".connect_ul1").css({"display":"block"})
			$(".connect_ul2").css({"display":"none"})
			$(".connect_top span:eq(0)").css("height","35px")
			$(".connect_top span:eq(1)").css("height","34px")
		})
		$(".connect_top span:eq(1)").hover(function(){
			$(".connect_ul1").css({"display":"none"})
			$(".connect_ul2").css({"display":"block"})
			$(".connect_top span:eq(0)").css("height","34px")
			$(".connect_top span:eq(1)").css("height","35px")
		})
	}
}
connectOA();
/////////////////////////认证、监察
function controlLi(){
	var $oControlLi = $(".medicine_control li");
//	console.log($oControlLi);
	$oControlLi.each(function(index,value){
		$(this).mouseenter(function(){
			$(this).animate({"background-position-y":"15px"},300).animate({"background-position-y":"30px"},300)
		})
	})
}
controlLi()








